@extends("layouts.backend.webadmin")
@section('page-header')
    <h1>
        <small>falw\menu</small>
    </h1>
@endsection

@section('content')
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/select2/css/select2.min.css">
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/select2/css/select2totree.css">
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        @if($errors->any())
                            <ul class="alert alert-danger">
                                @foreach($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        @endif
                        <form action="{{ URL::route('admin.flaw.add') }}" method="POST">
                            <div class="form-group">
                                <label for="parentmenu">父级分类</label>
                                <select class="form-control" id="parentmenu" name="pid">
                                    <option class="l1 non-leaf" value="0">选择父级菜单</option>
                                    @foreach($items as $item)
                                        <option class="l{{$item->num+1}} {{$item->child=='yes'?  'non-leaf':''}}" data-pup="{{$item->pid}}" value="{{ $item->id }}" @if ($item->id == old('pid')) selected @endif>{{ $item->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="menuname">标题</label>
                                <input type="text" class="form-control" id="menuname" placeholder="分类名称" name="title"
                                       value="{{old('title')}}">
                            </div>
                            <div class="form-group">
                                <label for="menualias">简称</label>
                                <input type="text" class="form-control" id="menualias" placeholder="分类简称" name="name"
                                       value="{{old('name')}}">
                            </div>
                            <div class="form-group">
                                <label for="keywords">关键词</label>
                                <input type="text" class="form-control" id="keywords" placeholder="关键词" name="keywords"
                                       value="{{old('keywords')}}">
                            </div>
                            <div class="form-group">
                                <label for="description">描述</label>
                                <input type="text" class="form-control" id="description" placeholder="描述"
                                       name="description" value="{{old('description')}}">
                            </div>
                            {!! csrf_field() !!}
                            <button type="submit" class="btn btn-success">确认添加</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
@stop
@section('javascript-end')
<script src="{{env('APP_ROOT')}}/assets/select2/js/select2.full.js"></script>
<script src="{{env('APP_ROOT')}}/assets/select2/js/i18n/zh-CN.js"></script>
<script src="{{env('APP_ROOT')}}/assets/select2/js/select2totree.js"></script>
<script>
//    $("select").select2({
//        placeholder: "选择父分类",
//        allowClear: true
//    });
    $('#parentmenu').select2ToTree({language: "zh-CN"});
</script>
@endsection